package com.example.active.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsMessagingTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.jms.Topic;
import java.util.UUID;

/**
 * @author 朝花不迟暮
 * @version 1.0
 * @date 2020/9/18 14:34
 */
@Component
public class TopicProducerBoot
{
    @Autowired
    private JmsMessagingTemplate jmsMessagingTemplate;

    @Autowired
    private Topic topic;

    @Scheduled(fixedDelay = 3000)
    public void productTopic()
    {
        jmsMessagingTemplate.convertAndSend(topic,"payload:"+ UUID.randomUUID().toString().substring(0,6));
    }
}
